<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../Another/Style/jquery-ui.css"/>
<script type="text/javascript" src="../Another/JQuery/jquery1.9.2.min.js"></script>
<script type="text/javascript" src="../Another/JQuery/jquery_ui.js"></script>
<link rel="stylesheet" type="text/css" href="../Another/Style/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="../Another/Style/bootstrap-responsive.css"/>
<script type="text/javascript" src="../Another/JQuery/bootstrap-transition.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-alert.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-modal.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-dropdown.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-scrollspy.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-tab.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-tooltip.js"></script>
<script type="text/javascript" src="../Another/JQuery/bootstrap-popover.js"></script>
<script type="text/javascript" src="../Another/JQuery/jquery.validate.js"></script>
<style>
.control-label{
	margin-left: 100px;
	margin-right: 10px;
}
</style>
<script type="text/javascript">
	  $(document).ready(function(){
			$('input').hover(function()
			{
			$(this).popover('show')
		});
			$("#registerHere").validate({
				rules:{
					MaNhom: "required",
					MaLoai:"required",
					TenSanPham: "required",
					NgayNhap: "required",
					MoTa:"required",
					HinhAnh: "required",
					DonGia:"required"
				},
				messages:{
					MaNhom: "Nhập vào nhóm sản phẩm",
					MaLoai:"Nhập vào loại sản phẩm",
					TenSanPham: "Nhập vào tên sản phẩm",
					NgayNhap: "Nhập vào ngày nhập",
					MoTa:"Nhập vào mô tả sản phẩm",
					HinhAnh: "thêm file hình vào",
					DonGia:"Nhập vào giá sản phẩm"
				},
				errorClass: "help-inline",
				errorElement: "span",
				highlight:function(element, errorClass, validClass) {
					$(element).parents('.control-group').addClass('error');
				},
				unhighlight: function(element, errorClass, validClass) {
					$(element).parents('.control-group').removeClass('error');
					$(element).parents('.control-group').addClass('success');
				}
			});
		});
</script>

<script>
$(function() {
$( "#datepicker" ).datepicker({
changeMonth: true,
changeYear: true
});
});
</script>

<script language="javascript">
 $(document).ready(function() {
  $('#MaNhom').change(function() {
   giatri = this.value;
   $('#MaLoai').load('../MyControl/ajax_loai.php?id_nhom=' + giatri);
  });
 });
</script>

<?php 
if (isset ($_REQUEST["MaSP"]))
{
	include_once "../MyControl/connection.php";
	$MaSanPham = $_REQUEST['MaSP'];
	$sql = "SELECT * FROM sanpham s, thuonghieu t , loaisanpham l,khuyenmai k WHERE s.MaKhuyenMai=k.MaKhuyenMai and s.MaThuongHieu=t.MaThuongHieu and s.maloai = l.maloai and MaSanPham='" .$MaSanPham."'";
	$result = mysql_query($sql);
	
	if($row = mysql_fetch_array($result))
	{
		$MaLoai = $row['MaLoai'];
		$TenChiTietLoai = $row['TenChiTietLoai'];
		$MaThuongHieu = $row['MaThuongHieu'];
		$TenThuongHieu = $row['TenThuongHieu'];
		$TenSanPham =$row['TenSanPham'];
		$NgayNhap = $row['NgayNhap'];
		$MoTa = $row['MoTa'];
		$HinhAnh = $row['HinhAnhSP'];
		$DonGia = $row['DonGiaDuKien'];
		$TinhTrang = $row['TinhTrang'];
		$KhuyenMai = $row['NoiDung'];	
		$MaKhuyenMai = $row['MaKhuyenMai'];
	}
}
?>

  <div class="container">
	  <div class="row">
	  		<div class="span8">
		<form class="form-horizontal" id="registerHere" method='post' action="../MyControl/capnhatsanpham.php" enctype="multipart/form-data">
	  <fieldset>
	    <legend>Cập Nhật Sản Phẩm</legend>
         <input type="hidden" class="input-xlarge" id="MaSanPham" name="MaSanPham" rel="popover" value="<?php if(isset($MaSanPham)) echo $MaSanPham;?>"/>
       <div class="control-group">
              <label class="control-label" for="input01">Nhóm Sản Phẩm</label>
              <div class="controls">
                <select name="MaNhom" id="MaNhom">
                    <option value="0">–Chọn Nhóm Sản Phẩm–</option>
                    <?php
                        $sql="select * from nhomsanpham";
                        $result=mysql_query($sql);
                        while($row=mysql_fetch_array($result)){
                            echo '<option value="'.$row["MaNhom"].'">'.$row["TenNhom"].'</option>';
                        }
						
                    ?>          
                </select>         
              </div>
        </div>
        
        <div class="control-group">
              <label class="control-label" for="input01">Khuyến mãi</label>
              <div class="controls">
                <select name="MaKhuyenMai" id="MaKhuyenMai">
                    <option value="<?php if(isset($MaKhuyenMai)) echo $MaKhuyenMai;?>"><?php if(isset($KhuyenMai)) echo $KhuyenMai;?></option>
                    <?php
                        $sql1="select * from khuyenmai";
                        $result1=mysql_query($sql1);
                        while($row1=mysql_fetch_array($result1))
						{
                            echo '<option value="'.$row1["MaKhuyenMai"].'">'.$row1["NoiDung"].'</option>';
                        }
                    ?>          
                </select>       
              </div>
        </div> 
        
        
	    <div class="control-group">
	      <label class="control-label" for="input01">Loại Sản Phẩm</label>
	      <div class="controls">
          <span id="sloai">
          <select name="MaLoai" id="MaLoai">
            	<option value="<?php if(isset($MaLoai)) echo $MaLoai;?>"><?php if(isset($MaLoai)) echo $TenChiTietLoai;?></option>
               
      		</select>
          </span>
	        
	      </div>
	</div>
	
    <div class="control-group">
              <label class="control-label" for="input01">Thương Hiệu</label>
              <div class="controls">
                <select name="MaThuongHieu" id="MaThuongHieu">
                    <option value="<?php if(isset($MaThuongHieu)) echo $MaThuongHieu;?>"><?php if(isset($MaThuongHieu)) echo $TenThuongHieu;?></option>
                    <?php
                        $sql="select * from thuonghieu";
                        $result=mysql_query($sql);
                        while($row=mysql_fetch_array($result))
						{
                            echo '<option value="'.$row["MaThuongHieu"].'">'.$row["TenThuongHieu"].'</option>';
                        }
						mysql_close($con);
                    ?>          
                </select>         
              </div>
        </div>
   
	 <div class="control-group">
		<label class="control-label" for="input01">Tên Sản Phẩm</label>
	      <div class="controls">
	        <input type="text" class="input-xlarge" id="TenSanPham" name="TenSanPham" rel="popover" value="<?php if(isset($TenSanPham)) echo $TenSanPham;?>"/>
	       
	      </div>
	</div>
	
	
	<div class="control-group">
		<label class="control-label" for="input01">Ngày Nhập</label>
	      <div class="controls">
	        <input type="text" class="input-xlarge" id="datepicker" name="NgayNhap" rel="popover" value="<?php if(isset($NgayNhap)) echo $NgayNhap;?>"/>
	       
	      </div>
	</div>
	
    <div class="control-group">
		<label class="control-label" for="input01">Mô Tả</label>
	      <div class="controls">
            <textarea name="MoTa" class="input-xlarge" id="MoTa" rel="popover">
            <?php if(isset($MoTa)) echo $MoTa;?>
            </textarea>
	       
	      </div>
	</div>
    
    <div class="control-group">
		<label class="control-label" for="HinhAnh">Hình Sản Phẩm</label>
	      <div class="controls">
	        <input type="file" class="input-xlarge" id="HinhAnh" name="HinhAnh" rel="popover"/>
	       
	      </div>
	</div>
    
    <div class="control-group">
		<label class="control-label" for="input01">Đơn Giá Dự Kiến</label>
	      <div class="controls">
	        <input type="text" class="input-xlarge" id="DonGia" name="DonGia" rel="popover" value='<?php if(isset($DonGia)) echo $DonGia;?>'/>
	       </div>
	</div>
   
    <div class="control-group">
		<label class="control-label" for="input01">Tình Trạng</label>
	      <div class="controls">
	        <input type="text" class="input-xlarge" id="TinhTrang" name="TinhTrang" rel="popover" value="<?php if(isset($TinhTrang)) echo $TinhTrang;?>"/>
	       </div>
	</div>
   
	<div class="control-group">
		<label class="control-label" for="input01"></label>
	      <div class="controls">
	       <button type="submit" class="btn btn-success" rel="tooltip" title="first tooltip" name="CapNhat">Cập Nhật</button>
           &nbsp;
            &nbsp;
             &nbsp;
              &nbsp;
	        <button type="reset" class="btn btn-success" rel="tooltip" title="first tooltip">Nhập Lại</button>
	      </div>
			
	</div>
	</fieldset>
	</form>
   </div>
	
		</div>
        
        
          </div><!--/row-->
        </div><!--/span-->
      </div><!--/row-->
